﻿Imports System.Data.OleDb

Public Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'This is for adding roles for users
        If User.IsInRole("ActiveUsers ") Then
            ph_activeUsers.Visible = True
        Else
            ph_activeUsers.Visible = False
        End If
    End Sub

    Protected Sub btn_ask_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_ask.Click
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim sql = "INSERT INTO Questions (QuestionTitle,QuestionDetails) VALUES (@f1,@f2)"
        Dim cmdDB = New OleDbCommand(sql, conn)
        conn.Open()
        cmdDB.Parameters.AddWithValue("@f1", tb_question.Text)
        cmdDB.Parameters.AddWithValue("@f2", tb_questionDetail.Text)
        cmdDB.ExecuteNonQuery()
        conn.Close()
        Response.Redirect("AddSucceeded.aspx")
    End Sub
End Class